<?php defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.mootools'); 
$css = JURI::base().'components/com_set/css/style.css';  
?>
<link href="<?php echo $css;?>" rel="stylesheet" type="text/css" />
<script language="javascript">
function getchild(area_ids){
	var postStr = 'id='+area_ids+'&temp='+Math.random();
	var url = "index.php?option=com_set&controller=area&task=getchild";
	var theAjax = new Ajax(url, {method: 'post',postBody: postStr});
	theAjax.addEvent('onSuccess', function(data) {showchild(data);});
    theAjax.request();	
}
function showchild(data){
	json=eval('('+data+')');
	$each(json, function(v)
                     {
						 alert(v.area_name);
                     });
}
</script>
<form action="index.php" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>           
            <th>
                <?php echo JText::_( 'Area Name' ); ?>
            </th>
            <th width="5">
                <?php echo JText::_( 'Area Id' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'Area Zip' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'Operate' ); ?>
            </th>
        </tr>            
    </thead>
    <?php
    $k = 0;
    for ($i=0, $n=count( $this->items ); $i < $n; $i++)
    {
        $row =& $this->items[$i];
        $link = 'index.php?option=com_set&controller=area&task=editstore&cid[]='. $row->area_ids ;
        ?>
        <tr class="<?php echo "row$k"; ?>" id="<?php echo "row$row->area_ids"; ?>">        	          
            <td>
                <?php if($row->haschild){?>
            	<span id="<?php echo "expandall$row->area_ids"; ?>" class="<?php echo "expandall$row->area_type"; ?>">
            	<a href="javascript:void(0);" onclick="getchild('<?php echo "$row->area_ids";?>');"><img src="images/expandall.png"></span>
            	<?php }else{?>
            	<span id="<?php echo "collapseall$k"; ?>" class="<?php echo "collapseall$row->area_type"; ?>"><img src="images/collapseall.png"></span>
            	<?php }?>
                <a href="<?php echo $link; ?>"><?php echo $row->area_name; ?></a>
            </td>
            <td>
                <a href="<?php echo $link; ?>"><?php echo $row->area_ids; ?></a>
            </td>
            <td>
                <a href="<?php echo $link; ?>"><?php echo $row->area_zip; ?></a>
            </td>
            <td>
                <?php if ($row->status==1){echo JText::_( 'Open' );}else{echo JText::_( 'Close' );}?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </table>
</div>
<input type="hidden" name="option" value="com_set" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="controller" value="store" />
</form>
